/*
 * Copyright (C) 2019 ByteDance Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bytedance.scene.ui;

import com.bytedance.scene.GroupSceneDelegate;
import com.bytedance.scene.Scene;
import com.bytedance.scene.SceneComponentFactory;
import com.bytedance.scene.group.GroupScene;
import com.bytedance.scene.utlity.Utility;
import ohos.aafwk.ability.fraction.Fraction;
import ohos.aafwk.content.IntentParams;


public class GroupSceneCompatUtility {
    private GroupSceneCompatUtility() {
    }

    public static final class Builder {

        private final Fraction mFragment;

        private final Class<? extends GroupScene> mRootSceneClazz;

        private IntentParams mRootSceneArguments;

        private final int mIdRes;
        private boolean mSupportRestore = false;

        private SceneComponentFactory mRootSceneComponentFactory;

        private String mTag = NavigationSceneCompatUtility.LIFE_CYCLE_FRAGMENT_TAG;
        private boolean mImmediate = true;

        private Builder(Fraction fragment, Class<? extends GroupScene> rootSceneClazz, int containerId) {
            this.mFragment = Utility.requireNonNull(fragment, "Fraction can't be null");
            this.mRootSceneClazz = Utility.requireNonNull(rootSceneClazz, "Root Scene class can't be null");
            this.mIdRes = containerId;
        }


        public GroupSceneCompatUtility.Builder rootSceneArguments(IntentParams rootSceneArguments) {
            this.mRootSceneArguments = rootSceneArguments;
            return this;
        }


        public GroupSceneCompatUtility.Builder supportRestore(boolean supportRestore) {
            this.mSupportRestore = supportRestore;
            return this;
        }


        public GroupSceneCompatUtility.Builder rootSceneComponentFactory(SceneComponentFactory rootSceneComponentFactory) {
            this.mRootSceneComponentFactory = rootSceneComponentFactory;
            return this;
        }


        public GroupSceneCompatUtility.Builder tag(String tag) {
            this.mTag = Utility.requireNonNull(tag, "Tag can't be null");
            return this;
        }


        public GroupSceneCompatUtility.Builder immediate(boolean immediate) {
            this.mImmediate = immediate;
            return this;
        }


        public GroupSceneDelegate build() {
            return setupWithFragment(this.mFragment, this.mIdRes, this.mRootSceneClazz, this.mRootSceneArguments, this.mRootSceneComponentFactory, this.mSupportRestore, this.mTag, this.mImmediate);
        }
    }


    public static GroupSceneCompatUtility.Builder setupWithFragment(final Fraction fragment,
                                                                    Class<? extends GroupScene> rootScene,
                                                                    int containerId) {
        return new Builder(fragment, rootScene, containerId);
    }


    private static GroupSceneDelegate setupWithFragment(final Fraction fragment,
                                                        int containerId,
                                                        Class<? extends Scene> sceneClazz,
                                                        IntentParams sceneArguments,
                                                        SceneComponentFactory rootSceneComponentFactory,
                                                        final boolean supportRestore,
                                                        final String tag,
                                                        final boolean immediate) {

        return null;
    }
}
